package cn.yj.netty.support.test.protocol;

import cn.yj.netty.common.MessageType;

import java.io.Serializable;

/**
 * 请求实体基本类型
 *
 * --------------
 *  header
 * --------------
 *
 * @author 永健
 * @since 2022-02-15 12:33
 */
public abstract class BasePacket<T> implements Serializable {
    private Header header;
    private T body;

    public BasePacket setMessageType(MessageType messageType){
        if (header==null){
            header =new Header();
        }
        header.setMessageType(messageType.getCode());
        return this;
    }

    public Header getHeader() {
        return header;
    }

    public BasePacket<T> setHeader(Header header) {
        this.header = header;
        return this;
    }

    public T getBody() {
        return body;
    }

    public BasePacket<T> setBody(T body) {
        this.body = body;
        return this;
    }
}
